package com.pairuan.service.service.impl;

import cn.dev33.satoken.stp.StpUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pairuan.service.entity.User;
import com.pairuan.service.mapper.UserMapper;
import com.pairuan.service.service.UserService;
import org.springframework.stereotype.Service;

/**
 * 用户服务实现类
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    @Override
    public Long login(String username, String password) {
        // 查询用户信息
//        User user = this.getOne(new LambdaQueryWrapper<User>()
//                .eq(User::getUsername, username));
//
//        if (user == null) {
//            throw new RuntimeException("用户不存在");
//        }
//
//        if (!password.equals(user.getPassword())) {
//            throw new RuntimeException("密码错误");
//        }
        User user = new User();
        user.setId(1l);
        // 登录成功，使用Sa-Token记录用户登录状态
        StpUtil.login(user.getId());
        String tokenValue = StpUtil.getTokenValue();
        return user.getId();
    }
} 